package com.monlyu.action.programming;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;

import com.monlyu.action.BaseAction;
import com.monlyu.bo.ProgrammingBo;
import com.monlyu.vo.Manuscript;
import com.monlyu.vo.ProStaffInfo;
import com.monlyu.vo.Progm2GaoJian;
import com.monlyu.vo.Programming;

/*******************************************************************************
 * 
 * <b>功能描述☞</b>新闻编排操作<br>
 * 
 * <b>开发公司☞</b>重庆唯尼科技有限公司<br>
 * <b>版权☞</b>本文件归重庆唯尼科技有限公司所有<br>
 * <b>项目名☞</b>news<br>
 * <b>文件路径☞</b>com.monlyu.action.programming.ProgramAction.java<br>
 * <b>开发日期☞</b>2010-2-11 <br>
 * 
 * @author chendan
 * @since JDK 5
 * @version 1.0.8
 * 
 ******************************************************************************/
public class EditProgramAction extends BaseAction {

	/** 稿件列表 */
	private List<Manuscript> manuscripts;

	/** 编排的节目单 */
	private Programming programming;

	private ProgrammingBo programmingBo;

	/** 稿件id列表 */
	private String idlist;

	private List<Progm2GaoJian> progm2GaoJians;

	/** 是否允许修改 */
	private boolean modify;

	private ProStaffInfo proStaffInfo;

	private Date beginDate;

	private Date endDate;

	private String contentInfo;

	private String subContentInfo;

	private boolean doAudit;

	public boolean isDoAudit() {
		return doAudit;
	}

	public void setDoAudit(boolean doAudit) {
		this.doAudit = doAudit;
	}

	public String getSubContentInfo() {
		return subContentInfo;
	}

	public void setSubContentInfo(String subContentInfo) {
		this.subContentInfo = subContentInfo;
	}

	public String getContentInfo() {
		return contentInfo;
	}

	public void setContentInfo(String contentInfo) {
		this.contentInfo = contentInfo;
	}

	public ProStaffInfo getProStaffInfo() {
		return proStaffInfo;
	}

	public void setProStaffInfo(ProStaffInfo proStaffInfo) {
		this.proStaffInfo = proStaffInfo;
	}

	public String getIdlist() {
		return idlist;
	}

	public void setIdlist(String idlist) {
		this.idlist = idlist;
	}

	public List<Progm2GaoJian> getProgm2GaoJians() {
		return progm2GaoJians;
	}

	public void setProgm2GaoJians(List<Progm2GaoJian> progm2GaoJians) {
		this.progm2GaoJians = progm2GaoJians;
	}

	public void setProgrammingBo(ProgrammingBo programmingBo) {
		this.programmingBo = programmingBo;
	}

	@Override
	public String execute() throws Exception {
		if (programming != null && programming.getId() != null) {
			programming = programmingBo.getProgramming(programming.getId());
		}
		return view("selectGaoJian.jsp");
	}

	/**
	 * 保存新闻编排顺序
	 * 
	 * @return
	 * @throws UnsupportedEncodingException
	 * @since chendan 2010-2-15
	 */
	public String editProgram() {
		if (programming == null) {
			// programming为空，不处理，页面上没有选择编排的日期和栏目
			return ajax();
		} else if (programming.getId() == null) {
			// programming不为空，id为空，则新建
			programmingBo.createProgramming(programming, idlist);
		} else if (programming.getId() != null) {
			// programming不为空，id不为空，则修改
			programmingBo.updateProg(programming, idlist, doAudit);
		}
		return ajax(programming.getId());
	}

	/**
	 * 编排节目单稿件信息
	 * 
	 * @return
	 * @since chendan 2010-2-11
	 */
	public String editProg2GaoJian() {
		// 保存修改的稿件信息
		programmingBo.editProg2GaoJian(contentInfo, programming);
		return ajax();
	}

	/**
	 * 栏目播出人员信息维护
	 * 
	 * @return
	 * @since chendan 2010-2-11
	 */
	public String editProStaff() {
		programmingBo.editProStaff(proStaffInfo);
		return ajax();
	}

	/**
	 * 稿件打分
	 * 
	 * @return
	 * @since chendan 2010-2-11
	 */
	public String editGrade() {
		programmingBo.editGrade(contentInfo);
		return ajax();
	}

	public List<Manuscript> getManuscripts() {
		return manuscripts;
	}

	public void setManuscripts(List<Manuscript> manuscripts) {
		this.manuscripts = manuscripts;
	}

	public Programming getProgramming() {
		return programming;
	}

	public void setProgramming(Programming programming) {
		this.programming = programming;
	}

	public boolean isModify() {
		return modify;
	}

	public void setModify(boolean modify) {
		this.modify = modify;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
